﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";

    var setting = (Setting)ViewBag.Setting;
}
@section Toolbar
{
    @if (setting.Type == (int)SettingType.Enum)
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "新建项", Click = "create(21)", Icon = "create"  })
    }
    else
    {
        @Html.MyNet().Button(new ButtonOptions { Text = "新建项", Icon = "create" }, new[] 
        {
            new ButtonOptions { Text = "新建字符串项", Click = "create(11)", Icon = "create"  },
            new ButtonOptions { Text = "新建文件项", Click = "create(12)", Icon = "create"  },
        })
    }
    @Html.MyNet().Button(new ButtonOptions { Text = "删除项", Click = "removee", Icon = "remove" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Menu
{
    @Html.MyNet().Menu(new ButtonOptions { Text = "修改项", Click = "modify" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "删除项", Click = "removee", Icon = "remove" })
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
<script>

    var settingId="@Request["SettingId"]";
    var url = "/Common/SettingItem/";

    jQuery(function ()
    {
        read();
    });

    function read()
    {
        $.ajax
        ({
            url: url + "Read?SettingId=" + settingId,
            data: query,
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                bind(result);
            }
        });
    }

    function create(type)
    {
        nav(url + "Create?SettingId=" + settingId + "&Type=" + type);
    }

    function modify()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Modify?Id=" + gridSelected()[0]);
    }

    function removee()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
        ({
            url: url + "Remove",
            data: { ids: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                read();
            }
        });
    }

</script>
